package com.winshare.saleAssistant.controller;

import com.winshare.saleAssistant.domain.dto.req.ParamCreateDTO;
import com.winshare.saleAssistant.service.SysParamService;
import com.winshare.saleAssistant.util.LogicResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sys/param")
@CrossOrigin
@Api(value = "系统参数设置",description = "系统参数设置")
public class SysParamController {

    private final SysParamService sysParamService;

    public SysParamController(SysParamService sysParamService) {
        this.sysParamService = sysParamService;
    }

    @PostMapping("/settingParam")
    @ApiOperation(value = "参数设置",notes = "参数设置")
    public LogicResponse settingParam(@RequestBody @Validated ParamCreateDTO paramCreateDTO) {
        sysParamService.saveSysParam(paramCreateDTO);
        return LogicResponse.success("success");
    }

    @PostMapping("/getSysParam")
    @ApiOperation(value = "获取参数",notes = "获取参数")
    public LogicResponse getSysParam() {
        return LogicResponse.success(sysParamService.getSysParam());
    }
}
